// API路由配置文件
// 统一管理所有后端API路由

// 导入环境配置
import config from './config'

// 基础配置
export const API_CONFIG = {
    BASE_URL: config.BASE_URL,
    TIMEOUT: config.TIMEOUT
}

// 用户相关路由
export const USER_ROUTES = {
    LOGIN: '/api/auth',          // POST: 用户登录获取Token
    REGISTER: '/api/users',      // POST: 用户注册
    GET_CURRENT_USER: '/api/user',    // GET: 获取当前登录用户信息
    CHECK_USERNAME: '/api/users/check', // GET: 检查用户名是否已存在
}

// 商家相关路由
export const BUSINESS_ROUTES = {
    LIST_BUSINESS: '/api/businesses',       // GET: 获取商家列表 (可带查询参数)
    GET_BUSINESS_BY_ID: '/api/businesses'   // GET: /api/businesses/{id} 获取单个商家
}

// 食品相关路由
export const FOOD_ROUTES = {
    LIST_FOOD_BY_BUSINESS_ID: '/api/foods' // GET /api/foods?business={businessId}
}

// 图片上传相关路由
export const IMAGE_ROUTES = {
    UPLOAD_BUSINESS_IMAGE: '/api/images/business',  // POST: 上传商家图片
    UPLOAD_FOOD_IMAGE: '/api/images/food'           // POST: 上传食品图片
}

// 购物车相关路由
export const CART_ROUTES = {
    LIST_CART: '/api/carts',             // GET: 获取当前用户购物车
    SAVE_CART: '/api/carts',             // POST: 添加商品到购物车
    UPDATE_CART: '/api/carts',           // PUT: 更新购物车商品数量
    REMOVE_CART: '/api/carts'            // DELETE: 删除购物车商品
}

// 订单相关路由
export const ORDER_ROUTES = {
    CREATE_ORDER: '/api/orders',           // POST: 创建订单
    LIST_MY_ORDERS: '/api/orders',         // GET: 获取当前用户订单列表
    GET_ORDER_DETAIL: '/api/orders',       // GET: /api/orders/{id} 获取订单基本信息
    GET_ORDER_DETAILETS: '/api/orders'     // GET: /api/orders/{id}/detailets 获取订单商品详情
}

// 退款相关路由
export const REFUND_ROUTES = {
    APPLY_REFUND: '/api/refunds',                // POST: /api/refunds/{orderId} 申请退款
    PROCESS_REFUND: '/api/refunds',              // POST: /api/refunds/{orderId}/process 处理退款申请
    CHECK_REFUND_ELIGIBILITY: '/api/refunds'     // GET: /api/refunds/{orderId}/eligibility 检查退款资格
}

// 地址相关路由
export const ADDRESS_ROUTES = {
    LIST_ADDRESSES: '/api/addresses',    // GET: 获取当前用户地址列表
    SAVE_ADDRESS: '/api/addresses',      // POST: 新增地址
    UPDATE_ADDRESS: '/api/addresses',    // PUT: /{id} 更新地址
    REMOVE_ADDRESS: '/api/addresses'     // DELETE: /api/addresses/{id} 删除地址
}

export const WALLET_ROUTES = {
    BASE: '/api/wallet',
    RECHARGE: '/api/wallet/recharge',
    WITHDRAW: '/api/wallet/withdraw',
    PAY: '/api/wallet/pay',
    REFUND: '/api/wallet/refund',
    TRANSFER: '/api/wallet/transfer',
    FREEZE: '/api/wallet/freeze',
    UNFREEZE: '/api/wallet/unfreeze',
    TRANSACTIONS: '/api/wallet/transactions',
    TRANSACTIONS_PERIOD: '/api/wallet/transactions/period',
    BALANCE_SUFFICIENT: '/api/wallet/balance/sufficient',
    RULES_ACTIVE: '/api/wallet/rules/active',
    RULES_DEPOSIT_APPLICABLE: '/api/wallet/rules/applicable-deposit',
    RULES: '/api/wallet/rules',
    RULE_ENABLE: '/api/wallet/rules/{ruleId}/enable',
    RULE_DISABLE: '/api/wallet/rules/{ruleId}/disable',
    // 透支管理相关路由
    OVERDRAFT_SET_LIMIT: '/api/wallet/overdraft/set-limit',
    OVERDRAFT_INCREASE: '/api/wallet/overdraft/increase',
    OVERDRAFT_DECREASE: '/api/wallet/overdraft/decrease'
}

// // 所有路由的统一导出
// export const ALL_ROUTES = {
//     USER: USER_ROUTES,
//     BUSINESS: BUSINESS_ROUTES,
//     FOOD: FOOD_ROUTES,
//     CART: CART_ROUTES,
//     ORDER: ORDER_ROUTES,
//     ADDRESS: ADDRESS_ROUTES
// }
